//
//  WCMacros.h
//  WonderCommon
//
//  Created by zero on 2020/7/17.
//

#ifndef WCMacros_h
#define WCMacros_h

//去掉空格回车
#define StringTrimming(_ref) [[_ref stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]


// 是否为空对象
#define WHObjectIsNil(__object)  ((nil == __object) || [__object isKindOfClass:[NSNull class]])

// 字符串为空
#define WHStringIsEmpty(__string) (WHObjectIsNil(__string) || (__string.length == 0))

// 字符串不为空
#define WHStringIsNotEmpty(__string)  (!WHStringIsEmpty(__string))

//屏幕尺寸
#define SCREEN_BOUNDS ([[UIScreen mainScreen] bounds])
#define SCREEN_WIDTH  [UIScreen mainScreen].bounds.size.width
#define SCREEN_HEIGHT [UIScreen mainScreen].bounds.size.height

/// 类型相关
#define WH_IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
#define WH_IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
#define WH_IS_RETINA ([[UIScreen mainScreen] scale] >= 2.0)

//statusbar 高度
#define STATUSBAR_HEIGHT [[UIApplication sharedApplication] statusBarFrame].size.height

#define NAVIGATIONBAR_HIGHT self.navigationController.navigationBar.frame.size.height

#define TABBAR_HEIGHT self.tabBarController.tabBar.frame.size.height

#define STATUSBAR_NAVIGATIONBAR_HEIGHT STATUSBAR_HEIGHT + NAVIGATIONBAR_HIGHT


// bundle Identifier
#define BUNDLEIDentiFIER [[NSBundle mainBundle] bundleIdentifier]

// app 版本
#define VERSION_NUM [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]

// app 版本
#define OS_VERSION [NSString stringWithFormat:@"iOS%@",[[UIDevice currentDevice] systemVersion]]

// app 版本
#define REQUEST_SECRET @"A8VlJnyjXXdK3Csw6ZAN4KM9jFGHFk1G"

// app 版本
#define IDFA_SECRET @"com.wonder.idfa.secret"

//颜色
#define ColorFromRGBA(rgbValue, a) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:(float)a]
#define ColorFromRGB(rgbValue) ColorFromRGBA(rgbValue, 1.0)

#define RGBA(r, g, b, a) [UIColor colorWithRed:r/255.0f green:g/255.0f blue:b/255.0f alpha:a]
#define RGB(r,g,b) RGBA(r, g, b, 1.0f)

#define IsPortrait ([[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationPortrait || [[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationPortraitUpsideDown)

//输出
#if DEBUG
#define NSLog(FORMAT, ...) fprintf(stderr,"[%s:%d行] %s\n",[[[NSString stringWithUTF8String:__FILE__] lastPathComponent] UTF8String], __LINE__, [[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String]);
#else
#define NSLog(FORMAT, ...) nil
#endif



#endif /* WCMacros_h */
